home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / 68hc11 / user_asc.icc < prev    next >
Text File  |  1994-10-20  |  17KB  |  437 lines

  1. ICC11 - DOS based C Cross Compiler for MC68HC11
  2.  
  3. User Manual version 0.43
  4. Feb. 8th, 1993
  5.  
  6. LICENSE AGREEMENT
  7.  
  8. This is a pre-general release version 0.43 of the ImageCraft C
  9. Cross Compiler for the Motorola MC68HC11 processors. There is no
  10. charge for a license to use this release of the product. This
  11. product is protected by copyright laws and is not in the public
  12. domain. This license and the use of this product expires when
  13. the general release (version 1.0) becomes available to the
  14. general public. This license will not cover the general release
  15. version, nor any subsequent releases.
  16.  
  17. The general release will contain a relocatable assembler and
  18. linker, and is estimated to  cost around $50.
  19.  
  20. WARRANTY INFORMATION
  21.  
  22. There is no warranty available on this version of the ImageCraft
  23. C Cross Compiler. This product and all related documentation are
  24. provided "AS IS." ImageCraft and the authors of this product do
  25. not warrant that this product will be bug-free, and since this
  26. is a pre-release version, there are likely to be bugs. UNDER NO
  27. CIRCUMSTANCES, INCLUDING NEGLIGENCE, SHALL IMAGECRAFT OR THE
  28. AUTHORS OF THIS PRODUCT BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR
  29. CONSEQUENTIAL DAMAGES THAT RESULT FROM THE USE OF OR INABILITY
  30. TO USE THIS PRODUCT.
  31.  
  32. If you do not agree with the above licensing agreement and
  33. warranty information, you have no right to use this product and
  34. you must destroy this copy of the product immediately.
  35.  
  36. Introduction
  37.  
  38. The ImageCraft C Cross Compiler for the MC68HC11 is a set of low
  39. cost standard conformance tools for programming in C and
  40. assembly on Motorola's 68HC11 series of microcontrollers. It
  41. consists of the following component programs:
  42.  
  43. icc11.exe
  44. - the driver program.
  45.  
  46. icpp.exe
  47. - the C preprocessor.
  48.  
  49. iccom11.exe
  50. - the compiler.
  51.  
  52. ias11.exe
  53. - the assembler.
  54.  
  55. crt.s
  56. - C runtime assembly file.
  57.  
  58. printf.c
  59. - simple printf-like function.
  60.  
  61. This manual does not describe how to write C or assembly
  62. programs. Any textbooks on ANSI standard C can be used for
  63. reference on C, and the assembler is based on the Motorola
  64. freeware version whose syntax is fairly well known and
  65. documentation for it can be obtained in many places. These
  66. programs accept file paths in either the Unix-style forward
  67. slash format or the DOS-style backward slash format.
  68.  
  69. If you use this product, please send us a message with your
  70. contact address so we may send you announcements of availability
  71. of new versions. Copies of the product on a 3 1/2" IBM disk can
  72. be obtained for a "shipping and handling" charge of $9.95. Of
  73. course, even though this version is available for free, a small
  74. contribution of between $5 to $10 will give us encouragement and
  75. incentive to continue development of this product (please make
  76. checks payable to Christina Willrich).
  77.  
  78. Currently, the best way to register and contact us are:
  79.  
  80. e-mail: imagecft@netcom.com, or
  81.  
  82. ImageCraft
  83. P.O.Box 64226, Sunnyvale, CA 94086-9991
  84.  
  85. Please report bugs to the contact address above. Machine
  86. configuration and a copy of the source code will help us to
  87. track down the bug. The compiler can generate information such
  88. as tables of variables' stack offsets, and line numbers as
  89. labels in the assembler output, both of which are helpful in
  90. tracking down your programming bugs and pinpointing compiler
  91. errors.
  92.  
  93. Since this release contains several unimplemented features, we
  94. would also appreciate it if you inform us which ones are most
  95. important to you, so that they can receive a high development
  96. priority.
  97.  
  98. Machine Requirements and Program limitations
  99.  
  100. This program runs in 8086 real modes under DOS, Windows VDM, OS2
  101. VDM and probably most DOS emulators on the popular Un*x and
  102. Mac*ntosh machines. A 32 bit protected mode version that runs on
  103. OS2 2.X and DOS can be obtained from us. The 32 bit version
  104. supports HPFS long filenames, wildcard expansion, has access to
  105. large memory space and executes faster than the 16 bit version,
  106. but otherwise is identical to it. The compiler should also run
  107. inside Integrated Development Environments such as IDEAL and
  108. Brief.
  109.  
  110. Unlike most other DOS-based compilers that have separate front
  111. end and back end programs, this is an integrated compiler in
  112. that the front end and the back end are a single monolithic
  113. program. This improves execution speed at the expense of
  114. requiring more conventional memory. The compiler does not use
  115. extended or expanded memory, so if you encounter an
  116. out-of-memory problem, your recourse is either: a) freeing up
  117. more conventional memory, b) reducing the size of the program,
  118. or c) acquiring the 32 bit version of the compiler.
  119.  
  120. The language preprocessor is close to ANSI C conformant and the
  121. C language accepted by the language processor is ANSI C
  122. conformant. The code generator does not yet support floating
  123. point code generation. long data type is the same size as the
  124. int data type, which is 2 bytes. In addition, the lcc compiler
  125. front end defines char data type as equivalent to signed char,
  126. which is unfortunate for the HC11 target since all computations
  127. smaller than int are promoted to int, and signed char promotions
  128. to int are more expensive than unsigned char promotions on the
  129. HC11.
  130.  
  131. There is no linker, librarian, debugger,or standard C headers
  132. and library in this release. Lack of a linker is not too much of
  133. a limitation since the assembler, compiler, and compiler driver
  134. have been written so that files of multiple types can be
  135. compiled and assembled together. A limited version of printf is
  136. provided.
  137.  
  138. Some of these limitations may be fixed in a later release.
  139.  
  140. The generated code should run on any version of the HC11, in
  141. both single-chip and expanded modes. 
  142.  
  143. Installation
  144.  
  145. Put all the .exe files in a directory in your path. Crt.s should
  146. be placed either in the same directory as your source or in the
  147. directory pointed to by the environment variable ICC11_LIB.
  148. Header files should be placed in the directory pointed to by the
  149. environment variable ICC11_INCLUDE.
  150.  
  151. To verify the system is set up correctly, type "icc11 -o dhry
  152. dhry.c printf.c" on the command line. You should see some
  153. (harmless) warnings from the preprocessor and an output file
  154. dhry.s19 should be produced.
  155.  
  156. Program Operation
  157.  
  158. This is a traditional compiler system where you invoke the
  159. compiler driver with your C and assembly source files, and if
  160. there is no error, an output file is produced. The output is a
  161. Motorola hex format file, suitable to download to a monitor
  162. program such as BUFFALO.
  163.  
  164. File paths can use either forward slash or backward slash
  165. format. In addition to the current directory, the preprocessor
  166. searches for header files in a directory specified by the
  167. environment variable ICC11_INCLUDE if it exists. The compiler
  168. driver also directs the preprocessor to search for system header
  169. files in /lcc/include by default.
  170.  
  171. Even though there is no separate relocatable linker in this
  172. release, the assembler can take multiple assembly source files
  173. and thus can be used in lieu of one. The code generator has been
  174. written such that any local symbol defined in a source file is
  175. distinct from generated local symbols in other source files
  176. (basically, local names are appended with the source file name)
  177. so that there should not be any local symbol name conflict.
  178.  
  179. The driver automatically invokes the assembler to assemble the
  180. file crt.s before other files that you specify. Crt.s contains
  181. several routines that the code generator emits for code that is
  182. too large to be generated inline. For example, multiply, divide
  183. and structure assignments routines are placed in there.
  184.  
  185. Crt.s also contains the startup code. The starting address for
  186. the code section (usually start of free RAM, or EEPROM), the
  187. starting address for data (usually external RAM or HC11 internal
  188. RAM) and the initial stack address are specified in here. You
  189. should modify these addresses to match your environment. This
  190. code fragment defines the starting address of the program, and
  191. the initial value of the stack pointer, then jumps to the C
  192. function main.
  193.  
  194. To use the printf function, you must define a function called
  195. putchar that outputs a single character and compile printf.c (or
  196. printf.s) with your files. The file crt.s contains a version of
  197. putchar that uses BUFFALO to do the output. You must replace it
  198. with something suitable for your system. This implementation of
  199. printf is very primitive. Please refer to the source code
  200. comment to see what it does support.
  201.  
  202. For systems with small amount of memory, an assembler listing
  203. should be generated to determine whether the program fits in the
  204. memory space or not. The compiler does not place any limit on
  205. the number or size of the local variables. However, due to the
  206. architecture of the HC11, you should consider placing large
  207. objects in static storage rather than on the stack since an
  208. indexed addressing mode can only access within 256 bytes of the
  209. frame pointer (as mentioned, the compiler does generate correct
  210. code to access objects with offset larger than 256 bytes off the
  211. frame pointer).
  212.  
  213. Debugging
  214.  
  215. The debug command line switch (-g) directs the compiler to emit
  216. labels of the form filename.line in the assembly output file
  217. where line is the source line number. The assembler listing file
  218. contains these labels and their actual code offset. Using these
  219. code offsets, breakpoints can be set in a debugger.
  220.  
  221. In the assembly output file, after each function label, the
  222. compiler emits a list of local variables and parameters with
  223. their corresponding offset off the frame pointer IX, as a
  224. comment block. Along with the debugging line labels above, it is
  225. relatively easy to inspect the source code and the listing file
  226. for debugging purposes.
  227.  
  228. Code Quality and Optimizations
  229.  
  230. Although the compiler does not perform register allocation or
  231. other resource-demanding global optimizations, it does perform
  232. basic block Common Subexpression Elimination in the front end,
  233. and branch shortening in the back end. Function arguments are
  234. passed in preallocated areas on the stack so no stack adjustment
  235. code is necessary after function calls. In addition, the
  236. compiler has a built-in peephole optimizer that walks through
  237. the generated code and eliminates redundant loads and stores,
  238. and replaces other inefficient code fragments with something
  239. shorter and faster.
  240.  
  241. Space or time critical code can be  either be written as C
  242. callable assembly routines, or assembler instructions can be
  243. embedded directly in the C source files.
  244.  
  245. Interfacing C With Assembly Routines
  246.  
  247. C global function and data names are prefixed with an '_', and
  248. arguments are pushed right to left and converted to their
  249. "natural size." That is, char and short are converted to int,
  250. and float is (or will be) converted into double. All arguments
  251. are passed on stack. D register contains the return value, if
  252. any. IX and IY registers can be used freely in an assembly
  253. routine. Argument stack space is allocated on function entry and
  254. thus does not need to be freed by the callee.
  255.  
  256. The assembler supports the "sect" pseudo op. "Sect 0" is the
  257. code section and "sect 1" is the data section. Each section has
  258. its own program counter. This is especially useful for using the
  259. HC11 in single chip mode where you may assign the code section
  260. to internal EEPROM and the data and stack sections to the
  261. internal RAM.
  262.  
  263. The compiler supports embedded assembly in the C source code.
  264. The format is
  265.  
  266.     asm("string");
  267.  
  268. "string" may contain variable references in the form of "%name."
  269. If name is a variable that is defined, the generated assembly
  270. replaces %name with the assembler references. If name is not a
  271. visible variable, then the literal "name" will be output. C
  272. escape sequences such as '\n' may be used inside the string.
  273. Note that an embedded assembly instruction must begin with a
  274. space or tab if it does not start with a label. Otherwise the
  275. assembler will generate an error.  For example, the following
  276. fragment:
  277.  
  278.  
  279.  
  280.     int external;
  281.     foo(int param)
  282.         {
  283.         int local;
  284.  
  285.         asm(" ldd %param");
  286.         asm("label: addd %local");
  287.         asm(" std %external");
  288.         asm(" ldd %xxx");        /* xxx is not a variable */
  289.         ...
  290.  
  291. may generate something like:
  292.  
  293.     ldd    2+2,x
  294. label:    addd    2-2,x
  295.     std    _external
  296.     ldd    xxx
  297.  
  298. You should not use "%?" inside the asm string, the output is
  299. meaningless. Note that the peephole optimizer does not optimize
  300. embedded asm code.
  301.  
  302. Command Syntax
  303.  
  304. icc11 [options] filenames
  305.  
  306. compiles the input files by invoking the appropriate processors
  307. to handle the input file types. The output is a Motorola hex
  308. format file, with an extension of .s19. Acceptable file types
  309. are: .c for C source file, .i for C source file after
  310. preprocessing, and .s file for assembly source file. Options are:
  311.  
  312. -v        verbose, prints out each action before execution. If
  313. specified more than once, no action gets executed.
  314. -o file    names the output file, default iccout.s19
  315. -l        creates an assembly listing file with name <output file
  316. name>.lst
  317. -E        preprocesses a .c file into an .i file
  318. -S        compiles into assembly but does not assemble.
  319. -s        silence mode. Will not print out each file name as the files
  320. are processed.
  321.  
  322. The following flags are passed directly to iccom11; please refer
  323. to their descriptions under that section.
  324.  
  325. -P
  326. -A
  327. -w
  328. -g
  329. -O        
  330.  
  331. icc11 also accepts other options, their behaviors are currently
  332. undefined.
  333.  
  334. icpp [options] input [output]
  335.  
  336. A complete description of this preprocessor and the flags can be
  337. found in cpp.mem. Some of the more important flags are:
  338.  
  339. -Dname[=value]
  340. define the word name to have the value. If value is not
  341. specified, then 1 is assumed
  342.  
  343. -Idirectory
  344. add directory to the search path for locating include files.
  345.  
  346. By default, icc11 specifies the -I/icc11/include to icpp.
  347.  
  348. iccom11 [options] input [output]
  349.  
  350. Compiles the preprocessed C source into assembly file. Options
  351. are:
  352.  
  353. -v        prints out compiler version string.
  354. -O0        disables the peephole optimizer.
  355. -P        generates function prototypes for functions encountered.
  356. Useful for converting non-ANSI programs to ANSI C.
  357.  
  358. -A        checks for strict ANSI conformance. If specified more than
  359. once, emits additional warnings.
  360. -w        do not generate warning.
  361. -g        generates debugging line labels.
  362.  
  363.  
  364. ias11 [options] filenames
  365.  
  366. Assembles the input files into a hex format output. All modules
  367. of a program must be specified, otherwise, an undefined symbol
  368. value error will result. Options are:
  369.  
  370. -l        generates a listing file.
  371. -o file    names the output file. Default is iccout.s19.
  372. -s        creates symbol table dump.
  373. -c        includes cycle counts in listing file.
  374. -cre        includes cross reference in listing file.
  375.  
  376. Known Bugs
  377.  
  378. _asm() only works inside a function definition. It also ought to
  379. work outside a function.
  380.  
  381. The debugging line number labels only use the base file name,
  382. and thus executable code defined inside an include file will not
  383. use the correct file name in the labels.
  384.  
  385. REXIS
  386.  
  387. A prime reason this compiler is written is so that hobbyists can
  388. experiment with REXIS (tm) (Real time EXecutive for Intelligent
  389. Systems). This release does not yet fully support REXIS since it
  390. is lacking several library functions. Here is an excerpt from
  391. the REXIS user manual:
  392.  
  393. REXIS (Real-time EXecutive for Intelligent Systems) is a small
  394. multitasking preemptive executive for embedded microcontroller
  395. systems. Based on both the designs of traditional real-time
  396. kernels and subsumption architecture as developed at the MIT
  397. Artificial Intelligence Laboratory for programming autonomous
  398. robots, REXIS provides a framework for implementing control
  399. programs for intelligent systems such as those used in robotic
  400. and distributed networks. It includes functions for managing
  401. tasks, messages, events, semaphores, scheduling, and memory
  402. allocation.
  403.  
  404. REXIS is written in portable ANSI C with a small assembly module
  405. for fast and efficient task switching. It is currently targeted
  406. for Motorola MC68HC11 microcontroller systems with at least 24K
  407. of RAM. Other targets are under consideration.
  408.  
  409. Please contact us if you are interested in REXIS or in using
  410. this compiler system with REXIS.
  411.  
  412. Acknowledgments
  413.  
  414. Most of the components in this current version are either in the
  415. public domain, or are copyrighted materials with permission for
  416. distribution. icc11 and the front end component of iccom11 are
  417. based on the lcc distribution written and copyright by David
  418. Hanson. The copyright information on these components are stated
  419. in the file readme.lcc. icpp is based on the public domain DECUS
  420. C preprocessor written by Martin Minow. The file readme.cpp is
  421. the readme file from the DECUS distribution. ias11 is based on
  422. the public domain assembler from Motorola. If you want
  423. information on how to obtain the sources for unmodified versions
  424. of these programs, please look in the relevant readme files or
  425. contact us.
  426.  
  427. The code generator component of the compiler, iccom11, is
  428. entirely of Richard Man's creation and is not based on any
  429. existing compiler technology. Christina Willrich is the resident
  430. English language / techwriting guru and helped to prepare
  431. anything that Richard has ever published or distributed. Thanks
  432. to Ariane (age 3) for letting us finally use the computer after
  433. she played "Busytown" for the zillionth time.
  434.  
  435. Copyright (C) 1993, 1994 by ImageCraft, Richard F. Man and
  436. Christina J. Willrich.
  437.